/******************************************************************************
 * * sms_ut.c - for ut test
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#include "sms_include.h"

void Sms_Test_Main(void)
{
// hal_rtc_t time;
    Hal_Init();
    printf("sms UT\n");
    UI_Common_Test_Main();
    UI_Normal_Common_init();
    Message_Init_Req();
    Sms_Main();

    Hal_Mem_Check_Start();

    // Mo_From_Framework();
}

VOID Contacts_Select_Contact_Req(IF_CONTACTS_SEL_CONTACT_TYPE Type)
{
    INT8                 name1[]   = "A";
    INT8                 name2[]   = "B";
    INT8                 number1[] = "123456789";
    INT8                 number2[] = "987654321";
    If_Contacts_Select_t *Contact  = NULL;
    UINT16               Count     = 0;
    INT8                 *pTemp;

    if (IF_CONTACTS_SMS_SEL_ONE_CONTACT == Type)
    {   // select one
        Count   = 1;
        Contact = (If_Contacts_Select_t *)Hal_Mem_Alloc(sizeof(If_Contacts_Select_t));
        Hal_Mem_Set(Contact, 0, sizeof(If_Contacts_Select_t));
        pTemp = strcpy(Contact->Name, name1);
        pTemp = strcpy(Contact->Number, number1);
        Contacts_SMS_Select_Contact_Cnf(Contact, Count);
    }
    else
    {   // select more than one
        Count   = 2;
        Contact = (If_Contacts_Select_t *)Hal_Mem_Alloc(sizeof(If_Contacts_Select_t) * Count);
        Hal_Mem_Set(Contact, 0, sizeof(If_Contacts_Select_t) * Count);
        pTemp = strcpy(Contact[0].Name, name1);
        pTemp = strcpy(Contact[0].Number, number1);
        pTemp = strcpy(Contact[1].Name, name2);
        pTemp = strcpy(Contact[1].Number, number2);
        Contacts_SMS_Select_Contact_Cnf(Contact, Count);
    }
    printf("%s\n", __FUNCTION__);
}

/**
 * Inform framework of the number of unread SMSs upon receipt of a new SMS
 * or all of unread SMSs being read.
 * param (in) Count: UINT8
 * return  VOID
 */
VOID Framework_Sms_Unread_Message_Ind(UINT8 Count)
{
    printf("%s\n", __FUNCTION__);
}

/**
 * Inform framework to dial
 * param (in) Number: INT8 *
 * return  VOID
 */
VOID Framework_Sms_Dial_Ind(INT8 *Number)
{
    Hal_Mem_Free(Number);
    printf("%s\n", __FUNCTION__);
}

/**
 * Get contact parameter related with phone number
 * param (in) Number: char *
 * param (out) ContactPara: If_Contacts_Contact_Para_t *
 * return  VOID
 */
VOID Contacts_Get_Contact_Para_Req(INT8 *Number, If_Contacts_Contact_Para_t *ContactPara)
{
    printf("%s\n", __FUNCTION__);
}

/**
 * Get contact number
 * param (in) Name: INT8*
 * return  INT8*: contact number
 */
INT8 *Contacts_Get_Contact_Number_Req(INT8 *Name)
{
    INT8 i      = 0;
    INT8 str[]  = "13512345888";
    INT8 *pTemp = NULL;

    i     = strlen(str);
    pTemp = Hal_Mem_Alloc(i + 1);
    Hal_Mem_Set(pTemp, 0, i + 1);
    strcpy(pTemp, str);
    printf("%s\n", __FUNCTION__);
    return(pTemp);
}

/**
 * Add number to number screening list from framework or SMS module
 * param (in) SrcActId: UINT16, refers to ACTIVITY_ID in nav.h
 * param (in) Number: INT8*, not free
 * return  VOID
 */
VOID Contacts_Add_Num_To_Scrn_List_Req(UINT16 SrcActId, INT8 *Number)
{
    printf("%s\n", __FUNCTION__);
}

/**
 * Delete number from number screening list
 * param (in) SrcActId: UINT16, refers to ACTIVITY_ID in nav.h
 * param (in) Number: INT8*, not free
 * return  VOID
 */
VOID Contacts_Del_Num_From_Scrn_List_Req(UINT16 SrcActId, INT8 *Number)
{
    printf("%s\n", __FUNCTION__);
}

/**
 * Enter number screening list
 * param (in) VOID
 * return  VOID
 */
VOID Contacts_Enter_Num_Scrn_List_Req(VOID)
{
    printf("%s\n", __FUNCTION__);
}

/**
 * Initiate framework module
 * param (in) Type: IF_FRAMEWORK_INIT_TYPE
 * return  VOID
 */
VOID Framework_App_Register_Req(If_Framework_Reg_Info_t *RegInfo)
{
    printf("%s\n", __FUNCTION__);
}

/**
 * Get number screening list from contacts APP
 * param (in) VOID
 * return  INT8*: dyadic array, NV_CONTACTS_MAX_NUMBER_IN_SCRN_LIST_NUM * NV_CONTACTS_MAX_NUMBER_LEN
 */
INT8 *Contacts_Get_Num_Scrn_List_Req(VOID)
{
    UINT8 i     = 0;
    INT8  str[] = "\0";
    INT8  *p    = Hal_Mem_Alloc(310);

    for (i = 0; i < 10; i++)
    {
        strcpy(&p[i * NV_CONTACTS_MAX_NUMBER_LEN], str);
    }
    return(p);
}
